package com.flightan.app.controller;

import com.flightan.app.model.Flight;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.ArrayList;

/**
 * Created by IntelliJ IDEA.
 * User: Aleks
 * Date: 18.03.12
 * Time: 18:03
 * To change this template use File | Settings | File Templates.
 */
@Controller
public class Flights
{
    ArrayList<Flight> shedulerTest = new ArrayList<Flight>();
    int i =0;
    @RequestMapping("/flight")
    public String getLists(Model model)
    {
//        Kurumoch kurumoch = new Kurumoch();
//        List<Flight> departureList = kurumoch.getDepartureFlights();
//        model.addAttribute("flightList", departureList);
        model.addAttribute("flightList", shedulerTest);
        return "flightsList";
    }

    @Scheduled(fixedDelay=1000)
    public void updateFlight()
    {
        Flight f = new Flight();
        f.setFlightID(String.valueOf(i++));
        shedulerTest.add(f);
    }
}
